package com.baozhun.mall.common.util

import com.baozhun.mall.common.model.bean.ClassifyInfo


/**
 * @Title：
 * @Description：
 * @Author：xuefeng.zhu
 * @Since：2023/10/31
 * @Version：1.0.0
 */
object AppUtil {


    /**
     * 转换分类数据
     */
    fun <T> transformClassData(list: ArrayList<T>?, pageSize: Int): MutableList<MutableList<T>> {
        var mutableList = arrayListOf<MutableList<T>>()
            if (list.isNullOrEmpty()) return mutableList

        var totalPage = list.size / pageSize

        for (i in 0 until totalPage) {
            mutableList.add(list.subList(i * pageSize, pageSize * (i + 1)))
        }
        //看是否有余数,有余数则加上余数
        var remainder = list.size % pageSize
        if (remainder != 0) {
            mutableList.add(list.subList(totalPage * pageSize, list.size))
        }
        return mutableList
    }


}